import type { RoomSummaryModel } from "../model/room.model.ts";
import { http } from "@/api";


/**
 * 创建房间
 * @param data 房间信息数据
 */
export function createRoom(
    data: {
        name: string,
        password?: string,
        capacity: number
    }
): Promise<RoomSummaryModel> {
    return http({
        method: "POST",
        url: "/room",
        data
    });
}

/**
 * 获取房间列表
 */
export function fetchRoomList(): Promise<Array<RoomSummaryModel>> {
    return http({
        method: "GET",
        url: "/room/list"
    });
}

/**
 * 验证房间密码
 */
export function verifyRoomPwd(data: { rid: string, pwd: string }): Promise<boolean> {
    return http({
        method: "POST",
        url: "/room/pwd",
        data
    });
}